package com.akkainaction.tool.scheduler;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Cancellable;
import akka.actor.Props;
import com.akkainaction.tool.scheduler.actor.TargetActor;
import scala.concurrent.duration.Duration;

import java.util.concurrent.TimeUnit;

public class TestScheduler {

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("sys");
        ActorRef targetActorRef = system.actorOf(Props.create(TargetActor.class), "targetActor");
        Cancellable cancellable = system.scheduler().schedule(Duration.create(3, TimeUnit.SECONDS),
                Duration.create(10, TimeUnit.SECONDS),
                targetActorRef, "hello", system.dispatcher(), ActorRef.noSender());
        //如果想取消scheduler，调用Cancellable的cancel方法
        //cancellable.cancel();
    }
}
